package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.RoleQuery;
import com.gec.zhs.entity.po.Role;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.RoleService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 角色表 Controller
 */
@RestController("roleController")
@RequestMapping("/role")
public class RoleController extends ABaseController{

	@Resource
	private RoleService roleService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(RoleQuery query){
		return getSuccessResponseVO(roleService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Role bean) {
		roleService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Role> listBean) {
		roleService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Role> listBean) {
		roleService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getRoleById")
	public ResponseVO getRoleById(String id) {
		return getSuccessResponseVO(roleService.getRoleById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateRoleById")
	public ResponseVO updateRoleById(Role bean,String id) {
		roleService.updateRoleById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteRoleById")
	public ResponseVO deleteRoleById(String id) {
		roleService.deleteRoleById(id);
		return getSuccessResponseVO(null);
	}
}